<%--
  Created by IntelliJ IDEA.
  User: dailyblue
  Date: 2025/7/15
  Time: 16:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h3>pageContext对象</h3>
<%
    // 获取到其他对象
    ServletRequest req = pageContext.getRequest();
    ServletResponse resp = pageContext.getResponse();
    HttpSession session1 = pageContext.getSession();
    ServletContext app = session1.getServletContext();
    // 可以直接操作四大容器
    pageContext.setAttribute("A", "aaa", 1);
    pageContext.setAttribute("B1", "bbb", 2);
    request.setAttribute("B2", "bbb2");
    pageContext.setAttribute("C1", "ccc", 3);
    session.setAttribute("C2", "ccc2");
    pageContext.setAttribute("D1", "ddd", 4);
    application.setAttribute("D2", "ddd2");
%>
<%=pageContext.getAttribute("A")%><br/>
<%=pageContext.getAttribute("B1", 2)%>
<%=pageContext.getAttribute("B2", 2)%>
<%=request.getAttribute("B1")%>
<%=request.getAttribute("B2")%><br/>
<%=pageContext.getAttribute("C1", 3)%>
<%=pageContext.getAttribute("C2", 3)%>
<%=session.getAttribute("C1")%>
<%=session.getAttribute("C2")%><br/>
<%=pageContext.getAttribute("D1", 4)%>
<%=pageContext.getAttribute("D2", 4)%>
<%=application.getAttribute("D1")%>
<%=application.getAttribute("D2")%><br/>

</body>
</html>
